package com.lgs.demo.customview;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.lgs.demo.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lgs on 2018/3/2.
 */

public class ShowDialogFragment extends DialogFragment {

    @BindView(R.id.tv_reduce)
    TextView tvReduce;
    @BindView(R.id.tv_count)
    TextView tvCount;
    @BindView(R.id.tv_add)
    TextView tvAdd;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_ok)
    TextView tvOk;

    public static ShowDialogFragment getInstance() {
        return new ShowDialogFragment();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_show, container, false);
        ButterKnife.bind(this, rootView);
        return rootView;
    }


    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new Dialog(getActivity(), R.style.CustomDialog);
    }

    @OnClick({R.id.tv_reduce, R.id.tv_add, R.id.tv_cancel, R.id.tv_ok})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_reduce:
                Toast.makeText(getContext(), "减少", Toast.LENGTH_SHORT).show();
                break;
            case R.id.tv_add:
                Toast.makeText(getContext(), "增加", Toast.LENGTH_SHORT).show();
                break;
            case R.id.tv_cancel:
                dismiss();
                break;
            case R.id.tv_ok:
                dismiss();
                break;
        }
    }
}
